package com.ywq.service.impl;

import com.ywq.dao.StudentDao;
import com.ywq.pojo.SSM_Student;
import com.ywq.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao sd;

    //增
    @Override
    public boolean add(SSM_Student student) {
        int n=sd.saveStudent(student);
        if(n>0){
            return true;
        }
        return false;
    }

    //删
    @Override
    public boolean deleteStudent(int id) {
        return sd.deleteStudent(id);
    }


    //改
    @Override
    public boolean updateStudent(SSM_Student stu) {
        return sd.updateStudent(stu);
    }

    //查
    @Override
    public SSM_Student findStudentById(int id) {
        SSM_Student stu = sd.findStudentById(id);
        return stu;
    }

    @Override
    public List<SSM_Student> findStudentBySex(String sex) {
        //调用Dao的方法
        List<SSM_Student> listStudentForSex=sd.findStudentBySex(sex);
        return listStudentForSex;
    }

    //查所有学生
    @Override
    public List<SSM_Student> findAll() {
        List<SSM_Student> allStudent = sd.findAll();
        return allStudent;
    }

}
